home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan
/
Opus 5 - Magellan.iso
/
Extras
/
DOpusLhARexx2
/
ARexx
/
LhaHandler.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-07-01
|
5KB
|
200 lines
/*rx
*
* LhaHandler - a Custom Handler for ListLha.rexx. Processes messages from
* DOpus when the user double/click-m-click's on a CustEntry.
*
* $VER: LhaHandler 40.1 (23/05/94) by Geoff Seeley
*
* Usage: Run RX LhaHandler.rexx >NIL:
* (from S:User-Startup)
*
*/
/*--------------------------------------------------------------------------*/
/* configuration variables (change these to suit your setup) */
LhaCommand = 'XFH_Work:C/Archivers/File/LhA '
ViewLhaFile = 'RX DOpus:ARexx/ViewLhAFile.rexx'
OutputWindow = '>CON:30/145/640/100/LhA_Output/CLOSE/SCREENDOPUS.1 '
InputWindow = '<CON:30/245/640/50/LhA_Input/AUTO/SCREENDOPUS.1 '
/*--------------------------------------------------------------------------*/
/* misc. variables */
DOpusPort = 'DOPUS.1'
LhaListPort = 'LHALIST.1'
/* need rexxsupport.library for message functions */
if ~show(l,"rexxsupport.library") then
call addlib("rexxsupport.library",0,-30,0)
/* check if we are already running */
if showlist('Ports', LhaListPort) then do
/* for multiple DOpus's, need to make port based on the port of the
DOpus who called us, but for now: */
/* can't run more than one handler... */
call ExitIt
end
options results
/* open our message port */
OurPort = openport(LhaListPort)
HandlerStatus = 'OPEN'
do until HandlerStatus = 'CLOSE'
call waitpkt(LhaListPort)
Packet = getpkt(LhaListPort)
if Packet ~= null() then do
Cmd = getarg(Packet, 0)
if Cmd = '1' | Cmd = '2' then do
Arg1 = getarg(Packet, 1) /* entry number */
Arg2 = getarg(Packet, 2) /* entry text */
Arg3 = getarg(Packet, 3) /* userdata */
call reply(Packet, 0)
address value DOpusPort
Busy on
if Cmd = '1' then
call HandleDoubleClick
else
call HandleClickMClick
Busy off
end
else
call reply(Packet, 0)
if Cmd = 'CLOSE' then
HandlerStatus = 'CLOSE'
end
end
/* close up shop */
call closeport(OurPort)
exit
/*--------------------------------------------------------------------------*/
HandleDoubleClick: /* double click, view file */
/* re-select this entry (double click unselects) */
'SelectEntry '||Arg1||' 1 1'
/* call view script */
address COMMAND ViewLhaFile
return
/*--------------------------------------------------------------------------*/
HandleClickMClick: /* click-m-click, extract file */
/* get env: settings */
LhaExtractCmd = GetLhaOpts()
/* get filename and path */
FileName = substr(Arg2, 10)
TopText "Extracting "||IsolateFilename(FileName)
if ExtOpts ~= '-x x' then
FileName = IsolateFilename(FileName)
/* get LhA archive name and path */
OtherWindow
'Status 14 -1'
LhaArchive = result
call FindLhAPath
LhaArchive = LhaPath || LhaArchive
/* unselect the file while we're here */
'SelectEntry '||Arg1||' 0 1'
/* get destination directory */
OtherWindow
'Status 13 -1'
DestinationPath = result
/* extract that puppy */
CliCommand = LhaCommand || OutputWindow || InputWindow || LhaExtractCmd ||'"'|| LhaArchive||'"'
CliCommand = CliCommand || ' "'||FileName||'" "'||DestinationPath||'"'
address command CliCommand
'Rescan -1'
TopText "Finished Extracting "||IsolateFilename(FileName)
return
/*--------------------------------------------------------------------------*/
FindLhAPath: /* grab invisible file path to archive */
/* find number of entries, path is the last one */
'Status 6 -1'
GetEntry Result
LhaPath = Result
return
/*--------------------------------------------------------------------------*/
IsolateFilename: /* given a device/path/file, return filename */
parse arg FilePath
DivPos = max(lastpos(':', FilePath),lastpos('/', FilePath)) +1
parse var FilePath PathSpec =DivPos AFileName
return AFileName
/*--------------------------------------------------------------------------*/
GetLhaOpts: procedure expose ExtOpts OvrOpts /* get LhA options */
if open('opts', 'ENV:LHAREXX_EXT_OPTS', 'R') then do
ExtOpts = readln('opts')
close('opts')
end
else
ExtOpts = '-x x '
if open('opts', 'ENV:LHAREXX_OVR_OPTS', 'R') then do
OvrOpts = readln('opts')
close('opts')
end
else
OvrOpts = '-m0 '
Opts = OvrOpts||ExtOpts
return Opts
/*--------------------------------------------------------------------------*/
ExitIt:
exit
return